{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"1002\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  const force = true;\n",
       "\n",
       "  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  const JS_MIME_TYPE = 'application/javascript';\n",
       "  const HTML_MIME_TYPE = 'text/html';\n",
       "  const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  const CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    const script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    const cell = handle.cell;\n",
       "\n",
       "    const id = cell.output_area._bokeh_element_id;\n",
       "    const server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id != null && id in Bokeh.index) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd_clean, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            const id = msg.content.text.trim();\n",
       "            if (id in Bokeh.index) {\n",
       "              Bokeh.index[id].model.document.clear();\n",
       "              delete Bokeh.index[id];\n",
       "            }\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd_destroy);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    const output_area = handle.output_area;\n",
       "    const output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      const bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      const script_attrs = bk_div.children[0].attributes;\n",
       "      for (let i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "        toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      const toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[toinsert.length - 1]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    const events = require('base/js/events');\n",
       "    const OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  const NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    const el = document.getElementById(\"1002\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) {\n",
       "        if (callback != null)\n",
       "          callback();\n",
       "      });\n",
       "    } finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.debug(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(css_urls, js_urls, callback) {\n",
       "    if (css_urls == null) css_urls = [];\n",
       "    if (js_urls == null) js_urls = [];\n",
       "\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
       "\n",
       "    function on_load() {\n",
       "      root._bokeh_is_loading--;\n",
       "      if (root._bokeh_is_loading === 0) {\n",
       "        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
       "        run_callbacks()\n",
       "      }\n",
       "    }\n",
       "\n",
       "    function on_error(url) {\n",
       "      console.error(\"failed to load \" + url);\n",
       "    }\n",
       "\n",
       "    for (let i = 0; i < css_urls.length; i++) {\n",
       "      const url = css_urls[i];\n",
       "      const element = document.createElement(\"link\");\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error.bind(null, url);\n",
       "      element.rel = \"stylesheet\";\n",
       "      element.type = \"text/css\";\n",
       "      element.href = url;\n",
       "      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
       "      document.body.appendChild(element);\n",
       "    }\n",
       "\n",
       "    for (let i = 0; i < js_urls.length; i++) {\n",
       "      const url = js_urls[i];\n",
       "      const element = document.createElement('script');\n",
       "      element.onload = on_load;\n",
       "      element.onerror = on_error.bind(null, url);\n",
       "      element.async = false;\n",
       "      element.src = url;\n",
       "      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.head.appendChild(element);\n",
       "    }\n",
       "  };\n",
       "\n",
       "  function inject_raw_css(css) {\n",
       "    const element = document.createElement(\"style\");\n",
       "    element.appendChild(document.createTextNode(css));\n",
       "    document.body.appendChild(element);\n",
       "  }\n",
       "\n",
       "  \n",
       "  const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.2.min.js\"];\n",
       "  const css_urls = [];\n",
       "  \n",
       "\n",
       "  const inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "    \n",
       "    \n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if (root.Bokeh !== undefined || force === true) {\n",
       "      \n",
       "    for (let i = 0; i < inline_js.length; i++) {\n",
       "      inline_js[i].call(root, root.Bokeh);\n",
       "    }\n",
       "    if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      const cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(css_urls, js_urls, function() {\n",
       "      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  const force = true;\n\n  if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  const NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    const el = document.getElementById(\"1002\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) {\n        if (callback != null)\n          callback();\n      });\n    } finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.debug(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(css_urls, js_urls, callback) {\n    if (css_urls == null) css_urls = [];\n    if (js_urls == null) js_urls = [];\n\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n    function on_load() {\n      root._bokeh_is_loading--;\n      if (root._bokeh_is_loading === 0) {\n        console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n        run_callbacks()\n      }\n    }\n\n    function on_error(url) {\n      console.error(\"failed to load \" + url);\n    }\n\n    for (let i = 0; i < css_urls.length; i++) {\n      const url = css_urls[i];\n      const element = document.createElement(\"link\");\n      element.onload = on_load;\n      element.onerror = on_error.bind(null, url);\n      element.rel = \"stylesheet\";\n      element.type = \"text/css\";\n      element.href = url;\n      console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n      document.body.appendChild(element);\n    }\n\n    for (let i = 0; i < js_urls.length; i++) {\n      const url = js_urls[i];\n      const element = document.createElement('script');\n      element.onload = on_load;\n      element.onerror = on_error.bind(null, url);\n      element.async = false;\n      element.src = url;\n      console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.head.appendChild(element);\n    }\n  };\n\n  function inject_raw_css(css) {\n    const element = document.createElement(\"style\");\n    element.appendChild(document.createTextNode(css));\n    document.body.appendChild(element);\n  }\n\n  \n  const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.2.min.js\"];\n  const css_urls = [];\n  \n\n  const inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    function(Bokeh) {\n    \n    \n    }\n  ];\n\n  function run_inline_js() {\n    \n    if (root.Bokeh !== undefined || force === true) {\n      \n    for (let i = 0; i < inline_js.length; i++) {\n      inline_js[i].call(root, root.Bokeh);\n    }\n    if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      const cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(css_urls, js_urls, function() {\n      console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.plotting import output_notebook,figure,show\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据准备模块\n",
    "from bokeh.models import ColumnDataSource"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"9d084f3a-f4cb-4891-86e5-1ce27d802d19\" data-root-id=\"1004\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  const docs_json = {\"cd529b0b-d09e-4cf3-bbe2-7f1b95128ce7\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1015\"}],\"center\":[{\"id\":\"1017\"},{\"id\":\"1021\"},{\"id\":\"1060\"}],\"left\":[{\"id\":\"1018\"}],\"outline_line_color\":null,\"renderers\":[{\"id\":\"1048\"},{\"id\":\"1066\"},{\"id\":\"1083\"}],\"title\":{\"id\":\"1005\"},\"toolbar\":{\"id\":\"1030\"},\"width\":500,\"x_range\":{\"id\":\"1007\"},\"x_scale\":{\"id\":\"1011\"},\"y_range\":{\"id\":\"1009\"},\"y_scale\":{\"id\":\"1013\"}},\"id\":\"1004\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1003\"}},\"id\":\"1084\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1038\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#c9d9d3\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#c9d9d3\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#c9d9d3\"},\"top\":{\"expr\":{\"id\":\"1039\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1046\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1038\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#c9d9d3\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#c9d9d3\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#c9d9d3\"},\"top\":{\"expr\":{\"id\":\"1039\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1047\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"2017\"},\"renderers\":[{\"id\":\"1083\"}]},\"id\":\"1095\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1039\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1038\"}},\"fill_color\":{\"value\":\"#c9d9d3\"},\"hatch_color\":{\"value\":\"#c9d9d3\"},\"line_color\":{\"value\":\"#c9d9d3\"},\"top\":{\"expr\":{\"id\":\"1039\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1045\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[]},\"id\":\"1038\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1003\"}},\"id\":\"1049\",\"type\":\"CDSView\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\",\"2017\"]},\"id\":\"1043\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1042\",\"type\":\"Stack\"},{\"attributes\":{\"coordinates\":null,\"formatter\":{\"id\":\"1055\"},\"group\":null,\"major_label_policy\":{\"id\":\"1056\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"1016\"}},\"id\":\"1015\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1016\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"fields\":[\"2015\",\"2016\"]},\"id\":\"1041\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1027\",\"type\":\"HelpTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1040\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#718dbf\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#718dbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#718dbf\"},\"top\":{\"expr\":{\"id\":\"1041\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1064\",\"type\":\"VBar\"},{\"attributes\":{\"coordinates\":null,\"formatter\":{\"id\":\"1052\"},\"group\":null,\"major_label_policy\":{\"id\":\"1053\"},\"minor_tick_line_color\":null,\"ticker\":{\"id\":\"1019\"}},\"id\":\"1018\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data\":{\"2015\":[2,1,4,3,2,4],\"2016\":[5,3,4,2,4,6],\"2017\":[3,2,4,4,5,3],\"fruits\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plunms\",\"Grapes\",\"Straeberries\"]},\"selected\":{\"id\":\"1058\"},\"selection_policy\":{\"id\":\"1057\"}},\"id\":\"1003\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis\":{\"id\":\"1015\"},\"coordinates\":null,\"grid_line_color\":null,\"group\":null,\"ticker\":null},\"id\":\"1017\",\"type\":\"Grid\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1003\"},\"glyph\":{\"id\":\"1045\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1047\"},\"name\":\"2015\",\"nonselection_glyph\":{\"id\":\"1046\"},\"view\":{\"id\":\"1049\"}},\"id\":\"1048\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1056\",\"type\":\"AllLabels\"},{\"attributes\":{\"label\":{\"value\":\"2015\"},\"renderers\":[{\"id\":\"1048\"}]},\"id\":\"1061\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1055\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"fields\":[\"2015\"]},\"id\":\"1040\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1057\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"tools\":[{\"id\":\"1022\"},{\"id\":\"1023\"},{\"id\":\"1024\"},{\"id\":\"1025\"},{\"id\":\"1026\"},{\"id\":\"1027\"},{\"id\":\"1029\"}]},\"id\":\"1030\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1019\",\"type\":\"BasicTicker\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1003\"},\"glyph\":{\"id\":\"1063\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1065\"},\"name\":\"2016\",\"nonselection_glyph\":{\"id\":\"1064\"},\"view\":{\"id\":\"1067\"}},\"id\":\"1066\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1040\"}},\"fill_color\":{\"value\":\"#718dbf\"},\"hatch_color\":{\"value\":\"#718dbf\"},\"line_color\":{\"value\":\"#718dbf\"},\"top\":{\"expr\":{\"id\":\"1041\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1063\",\"type\":\"VBar\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1028\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1025\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"$name\",\"@fruits:@$name\"]]},\"id\":\"1029\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"1023\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1040\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#718dbf\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#718dbf\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#718dbf\"},\"top\":{\"expr\":{\"id\":\"1041\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1065\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1052\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1058\",\"type\":\"Selection\"},{\"attributes\":{\"label\":{\"value\":\"2016\"},\"renderers\":[{\"id\":\"1066\"}]},\"id\":\"1078\",\"type\":\"LegendItem\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1003\"},\"glyph\":{\"id\":\"1080\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1082\"},\"name\":\"2017\",\"nonselection_glyph\":{\"id\":\"1081\"},\"view\":{\"id\":\"1084\"}},\"id\":\"1083\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis\":{\"id\":\"1018\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1021\",\"type\":\"Grid\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1042\"}},\"fill_color\":{\"value\":\"#e84d60\"},\"hatch_color\":{\"value\":\"#e84d60\"},\"line_color\":{\"value\":\"#e84d60\"},\"top\":{\"expr\":{\"id\":\"1043\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1080\",\"type\":\"VBar\"},{\"attributes\":{\"overlay\":{\"id\":\"1028\"}},\"id\":\"1024\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"1003\"}},\"id\":\"1067\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1053\",\"type\":\"AllLabels\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1042\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#e84d60\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#e84d60\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#e84d60\"},\"top\":{\"expr\":{\"id\":\"1043\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1082\",\"type\":\"VBar\"},{\"attributes\":{\"end\":16,\"start\":0},\"id\":\"1009\",\"type\":\"DataRange1d\"},{\"attributes\":{\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1061\"},{\"id\":\"1078\"},{\"id\":\"1095\"}],\"location\":\"top_left\",\"orientation\":\"horizontal\"},\"id\":\"1060\",\"type\":\"Legend\"},{\"attributes\":{\"factors\":[\"Apples\",\"Pears\",\"Nectarines\",\"Plunms\",\"Grapes\",\"Straeberries\"],\"range_padding\":0.1},\"id\":\"1007\",\"type\":\"FactorRange\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1042\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#e84d60\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#e84d60\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#e84d60\"},\"top\":{\"expr\":{\"id\":\"1043\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"fruits\"}},\"id\":\"1081\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1026\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1011\",\"type\":\"CategoricalScale\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1013\",\"type\":\"LinearScale\"},{\"attributes\":{\"coordinates\":null,\"group\":null,\"text\":\"Fruit Counts by Year\"},\"id\":\"1005\",\"type\":\"Title\"}],\"root_ids\":[\"1004\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.2\"}};\n",
       "  const render_items = [{\"docid\":\"cd529b0b-d09e-4cf3-bbe2-7f1b95128ce7\",\"root_ids\":[\"1004\"],\"roots\":{\"1004\":\"9d084f3a-f4cb-4891-86e5-1ce27d802d19\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    let attempts = 0;\n",
       "    const timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1004"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.core.properties import value\n",
    "fruits = ['Apples','Pears','Nectarines','Plunms','Grapes','Straeberries']\n",
    "years = [\"2015\",\"2016\",\"2017\"]\n",
    "colors = [\"#c9d9d3\", \"#718dbf\", \"#e84d60\"]\n",
    "data = {'fruits': fruits,\n",
    "        '2015' : [2,1,4,3,2,4],\n",
    "        '2016' : [5,3,4,2,4,6],\n",
    "        '2017' : [3,2,4,4,5,3]}\n",
    "\n",
    "source = ColumnDataSource(\n",
    "    data = data\n",
    ")\n",
    "\n",
    "# 点击的交互式数据\n",
    "TOOLTIPS = [\n",
    "#  (\"标题\"，\"数据\")\n",
    "    (\"$name\",\"@fruits:@$name\")\n",
    "]\n",
    "\n",
    "# 画布\n",
    "p = figure(\n",
    "    x_range = fruits,\n",
    "    plot_width=500,\n",
    "    title=\"Fruit Counts by Year\",\n",
    "    tooltips=TOOLTIPS\n",
    ")\n",
    "\n",
    "# 绘图\n",
    "p.vbar_stack(years,x='fruits',width=0.8,color = colors,source=source,legend=[value(x) for x in years])\n",
    "\n",
    "# 其他\n",
    "p.y_range.start = 0\n",
    "p.y_range.end = 16\n",
    "p.x_range.range_padding = 0.1\n",
    "p.xgrid.grid_line_color = None\n",
    "p.axis.minor_tick_line_color = None\n",
    "p.outline_line_color = None\n",
    "p.legend.location = \"top_left\"\n",
    "p.legend.orientation = \"horizontal\"\n",
    "# 显示\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "* 按照如下要求绘制上述DEMO 堆叠柱状图（本节实践，其中考核）\n",
    "> 1.筛选数据：居民人均可支配收入累计值（元）  \n",
    "> 2.堆叠：5个季度的时间顺序  \n",
    "> 3.x轴：地区  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>16230</td>\n",
       "      <td>54854</td>\n",
       "      <td>43592</td>\n",
       "      <td>28897</td>\n",
       "      <td>15472</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>6639</td>\n",
       "      <td>22306</td>\n",
       "      <td>17619</td>\n",
       "      <td>11490</td>\n",
       "      <td>6225</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22274</td>\n",
       "      <td>81518</td>\n",
       "      <td>61243</td>\n",
       "      <td>41381</td>\n",
       "      <td>21189</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10016</td>\n",
       "      <td>33303</td>\n",
       "      <td>26125</td>\n",
       "      <td>17383</td>\n",
       "      <td>9326</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>23772</td>\n",
       "      <td>82429</td>\n",
       "      <td>61915</td>\n",
       "      <td>42348</td>\n",
       "      <td>22636</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12891</td>\n",
       "      <td>38521</td>\n",
       "      <td>31985</td>\n",
       "      <td>22535</td>\n",
       "      <td>12006</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>22784</td>\n",
       "      <td>68487</td>\n",
       "      <td>52758</td>\n",
       "      <td>36294</td>\n",
       "      <td>21600</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>12541</td>\n",
       "      <td>35247</td>\n",
       "      <td>28474</td>\n",
       "      <td>20357</td>\n",
       "      <td>11686</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>城镇居民人均可支配收入累计值(元)</td>\n",
       "      <td>19251</td>\n",
       "      <td>57743</td>\n",
       "      <td>44267</td>\n",
       "      <td>30491</td>\n",
       "      <td>18194</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>农村居民人均可支配收入累计值(元)</td>\n",
       "      <td>10952</td>\n",
       "      <td>26791</td>\n",
       "      <td>20267</td>\n",
       "      <td>14455</td>\n",
       "      <td>10215</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0     居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "1   城镇居民人均可支配收入累计值(元)      16230      54854      43592      28897      15472   \n",
       "2   农村居民人均可支配收入累计值(元)       6639      22306      17619      11490       6225   \n",
       "3     居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "4   城镇居民人均可支配收入累计值(元)      22274      81518      61243      41381      21189   \n",
       "5   农村居民人均可支配收入累计值(元)      10016      33303      26125      17383       9326   \n",
       "6     居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "7   城镇居民人均可支配收入累计值(元)      23772      82429      61915      42348      22636   \n",
       "8   农村居民人均可支配收入累计值(元)      12891      38521      31985      22535      12006   \n",
       "9     居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "10  城镇居民人均可支配收入累计值(元)      22784      68487      52758      36294      21600   \n",
       "11  农村居民人均可支配收入累计值(元)      12541      35247      28474      20357      11686   \n",
       "12    居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "13  城镇居民人均可支配收入累计值(元)      19251      57743      44267      30491      18194   \n",
       "14  农村居民人均可支配收入累计值(元)      10952      26791      20267      14455      10215   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "1   广东省  \n",
       "2   广东省  \n",
       "3    北京  \n",
       "4    北京  \n",
       "5    北京  \n",
       "6   上海市  \n",
       "7   上海市  \n",
       "8   上海市  \n",
       "9   浙江省  \n",
       "10  浙江省  \n",
       "11  浙江省  \n",
       "12  江苏省  \n",
       "13  江苏省  \n",
       "14  江苏省  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "# 学生实践\n",
    "## 数据准备\n",
    "df = pd.read_csv('居民可支配收入.csv',sep=',',encoding='utf-8')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>2022年第一季度</th>\n",
       "      <th>2021年第四季度</th>\n",
       "      <th>2021年第三季度</th>\n",
       "      <th>2021年第二季度</th>\n",
       "      <th>2021年第一季度</th>\n",
       "      <th>地区</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>13360</td>\n",
       "      <td>44993</td>\n",
       "      <td>35694</td>\n",
       "      <td>23604</td>\n",
       "      <td>12636</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>20630</td>\n",
       "      <td>75002</td>\n",
       "      <td>56498</td>\n",
       "      <td>38138</td>\n",
       "      <td>19585</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>22663</td>\n",
       "      <td>78027</td>\n",
       "      <td>58907</td>\n",
       "      <td>40357</td>\n",
       "      <td>21548</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>19366</td>\n",
       "      <td>57541</td>\n",
       "      <td>44712</td>\n",
       "      <td>30998</td>\n",
       "      <td>18263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>居民人均可支配收入累计值(元)</td>\n",
       "      <td>16490</td>\n",
       "      <td>47498</td>\n",
       "      <td>36227</td>\n",
       "      <td>25119</td>\n",
       "      <td>15500</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 指标  2022年第一季度  2021年第四季度  2021年第三季度  2021年第二季度  2021年第一季度  \\\n",
       "0   居民人均可支配收入累计值(元)      13360      44993      35694      23604      12636   \n",
       "3   居民人均可支配收入累计值(元)      20630      75002      56498      38138      19585   \n",
       "6   居民人均可支配收入累计值(元)      22663      78027      58907      40357      21548   \n",
       "9   居民人均可支配收入累计值(元)      19366      57541      44712      30998      18263   \n",
       "12  居民人均可支配收入累计值(元)      16490      47498      36227      25119      15500   \n",
       "\n",
       "     地区  \n",
       "0   广东省  \n",
       "3    北京  \n",
       "6   上海市  \n",
       "9   浙江省  \n",
       "12  江苏省  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 筛选数据\n",
    "居民人均可支配收入 = df.query('指标==\"居民人均可支配收入累计值(元)\"')\n",
    "居民人均可支配收入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[12636, 19585, 21548, 18263, 15500]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "第一季度 = 居民人均可支配收入['2021年第一季度'].tolist()\n",
    "第一季度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[23604, 38138, 40357, 30998, 25119]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "第二季度 = 居民人均可支配收入['2021年第二季度'].tolist()\n",
    "第二季度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[35694, 56498, 58907, 44712, 36227]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "第三季度 = 居民人均可支配收入['2021年第三季度'].tolist()\n",
    "第三季度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[44993, 75002, 78027, 57541, 47498]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "第四季度 = 居民人均可支配收入['2021年第四季度'].tolist()\n",
    "第四季度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[13360, 20630, 22663, 19366, 16490]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "第五季度 = 居民人均可支配收入['2022年第一季度'].tolist()\n",
    "第五季度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['广东省', '北京', '上海市', '浙江省', '江苏省']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "area = 居民人均可支配收入['地区'].tolist()\n",
    "area"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[12636, 19585, 21548, 18263, 15500],\n",
       " [23604, 38138, 40357, 30998, 25119],\n",
       " [35694, 56498, 58907, 44712, 36227],\n",
       " [44993, 75002, 78027, 57541, 47498],\n",
       " [13360, 20630, 22663, 19366, 16490]]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "money = [第一季度,第二季度,第三季度,第四季度,第五季度]\n",
    "money"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n",
      "BokehDeprecationWarning: 'legend' keyword is deprecated, use explicit 'legend_label', 'legend_field', or 'legend_group' keywords instead\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "  <div class=\"bk-root\" id=\"346d0282-843a-4b97-8da1-9c073ba9317c\" data-root-id=\"1157\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    \n",
       "  const docs_json = {\"db484674-3bb2-4cf3-9b0c-435e1e493e32\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1168\"}],\"center\":[{\"id\":\"1170\"},{\"id\":\"1174\"},{\"id\":\"1217\"}],\"height\":500,\"left\":[{\"id\":\"1171\"}],\"renderers\":[{\"id\":\"1205\"},{\"id\":\"1223\"},{\"id\":\"1240\"},{\"id\":\"1257\"},{\"id\":\"1274\"}],\"title\":{\"id\":\"1158\"},\"toolbar\":{\"id\":\"1183\"},\"x_range\":{\"id\":\"1160\"},\"x_scale\":{\"id\":\"1164\"},\"y_range\":{\"id\":\"1162\"},\"y_scale\":{\"id\":\"1166\"}},\"id\":\"1157\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fields\":[]},\"id\":\"1191\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1169\",\"type\":\"CategoricalTicker\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"1198\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"1192\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1191\"}},\"fill_color\":{\"value\":\"#2b83ba\"},\"hatch_color\":{\"value\":\"#2b83ba\"},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"1192\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1202\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1164\",\"type\":\"CategoricalScale\"},{\"attributes\":{\"coordinates\":null,\"group\":null,\"text\":\"Fruit Counts by Year\"},\"id\":\"1158\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1162\",\"type\":\"DataRange1d\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1181\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1156\"},\"glyph\":{\"id\":\"1220\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1222\"},\"name\":\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1221\"},\"view\":{\"id\":\"1224\"}},\"id\":\"1223\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1166\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"1181\"}},\"id\":\"1177\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"coordinates\":null,\"formatter\":{\"id\":\"1209\"},\"group\":null,\"major_label_policy\":{\"id\":\"1210\"},\"ticker\":{\"id\":\"1172\"}},\"id\":\"1171\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1178\",\"type\":\"SaveTool\"},{\"attributes\":{\"axis\":{\"id\":\"1168\"},\"coordinates\":null,\"group\":null,\"ticker\":null},\"id\":\"1170\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1180\",\"type\":\"HelpTool\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1193\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#abdda4\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"1194\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1222\",\"type\":\"VBar\"},{\"attributes\":{\"axis\":{\"id\":\"1171\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1174\",\"type\":\"Grid\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\"]},\"id\":\"1193\",\"type\":\"Stack\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1191\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#2b83ba\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"1192\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1204\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1197\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#fdae61\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"1198\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1255\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1193\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#abdda4\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#abdda4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"1194\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1221\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1172\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1209\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1156\"},\"glyph\":{\"id\":\"1237\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1239\"},\"name\":\"\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1238\"},\"view\":{\"id\":\"1241\"}},\"id\":\"1240\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1195\"}},\"fill_color\":{\"value\":\"#ffffbf\"},\"hatch_color\":{\"value\":\"#ffffbf\"},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1196\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1237\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1223\"}]},\"id\":\"1235\",\"type\":\"LegendItem\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1156\"},\"glyph\":{\"id\":\"1271\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1273\"},\"name\":\"\\u7b2c\\u4e94\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1272\"},\"view\":{\"id\":\"1275\"}},\"id\":\"1274\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1210\",\"type\":\"AllLabels\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1195\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ffffbf\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1196\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1239\",\"type\":\"VBar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1199\"}},\"fill_color\":{\"value\":\"#d7191c\"},\"hatch_color\":{\"value\":\"#d7191c\"},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"1200\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1271\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"\\u7b2c\\u4e00\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1205\"}]},\"id\":\"1218\",\"type\":\"LegendItem\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1156\"},\"glyph\":{\"id\":\"1202\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1204\"},\"name\":\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1203\"},\"view\":{\"id\":\"1206\"}},\"id\":\"1205\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1195\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ffffbf\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#ffffbf\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ffffbf\"},\"top\":{\"expr\":{\"id\":\"1196\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1238\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1156\"}},\"id\":\"1258\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1199\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#d7191c\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"1200\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1273\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1212\",\"type\":\"CategoricalTickFormatter\"},{\"attributes\":{\"label\":{\"value\":\"\\u7b2c\\u56db\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1257\"}]},\"id\":\"1269\",\"type\":\"LegendItem\"},{\"attributes\":{\"source\":{\"id\":\"1156\"}},\"id\":\"1224\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1199\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#d7191c\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#d7191c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#d7191c\"},\"top\":{\"expr\":{\"id\":\"1200\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1272\",\"type\":\"VBar\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"1194\",\"type\":\"Stack\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"1197\",\"type\":\"Stack\"},{\"attributes\":{\"label\":{\"value\":\"\\u7b2c\\u4e09\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1240\"}]},\"id\":\"1252\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"\\u7b2c\\u4e09\\u5b63\\u5ea6\"]},\"id\":\"1196\",\"type\":\"Stack\"},{\"attributes\":{},\"id\":\"1213\",\"type\":\"AllLabels\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1156\"},\"glyph\":{\"id\":\"1254\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1256\"},\"name\":\"\\u7b2c\\u56db\\u5b63\\u5ea6\",\"nonselection_glyph\":{\"id\":\"1255\"},\"view\":{\"id\":\"1258\"}},\"id\":\"1257\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1191\"}},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2b83ba\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#2b83ba\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2b83ba\"},\"top\":{\"expr\":{\"id\":\"1192\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1203\",\"type\":\"VBar\"},{\"attributes\":{\"label\":{\"value\":\"\\u7b2c\\u4e94\\u5b63\\u5ea6\"},\"renderers\":[{\"id\":\"1274\"}]},\"id\":\"1286\",\"type\":\"LegendItem\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"\\u7b2c\\u56db\\u5b63\\u5ea6\"]},\"id\":\"1199\",\"type\":\"Stack\"},{\"attributes\":{\"source\":{\"id\":\"1156\"}},\"id\":\"1241\",\"type\":\"CDSView\"},{\"attributes\":{\"tools\":[{\"id\":\"1175\"},{\"id\":\"1176\"},{\"id\":\"1177\"},{\"id\":\"1178\"},{\"id\":\"1179\"},{\"id\":\"1180\"},{\"id\":\"1182\"}]},\"id\":\"1183\",\"type\":\"Toolbar\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1197\"}},\"fill_color\":{\"value\":\"#fdae61\"},\"hatch_color\":{\"value\":\"#fdae61\"},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"1198\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1254\",\"type\":\"VBar\"},{\"attributes\":{\"source\":{\"id\":\"1156\"}},\"id\":\"1275\",\"type\":\"CDSView\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1193\"}},\"fill_color\":{\"value\":\"#abdda4\"},\"hatch_color\":{\"value\":\"#abdda4\"},\"line_color\":{\"value\":\"#abdda4\"},\"top\":{\"expr\":{\"id\":\"1194\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1220\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1175\",\"type\":\"PanTool\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\",\"\\u7b2c\\u4e09\\u5b63\\u5ea6\",\"\\u7b2c\\u56db\\u5b63\\u5ea6\",\"\\u7b2c\\u4e94\\u5b63\\u5ea6\"]},\"id\":\"1200\",\"type\":\"Stack\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"$name\",\"@area:@$name\"]]},\"id\":\"1182\",\"type\":\"HoverTool\"},{\"attributes\":{\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1218\"},{\"id\":\"1235\"},{\"id\":\"1252\"},{\"id\":\"1269\"},{\"id\":\"1286\"}]},\"id\":\"1217\",\"type\":\"Legend\"},{\"attributes\":{},\"id\":\"1176\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"data\":{\"area\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"],\"\\u7b2c\\u4e00\\u5b63\\u5ea6\":[12636,19585,21548,18263,15500],\"\\u7b2c\\u4e09\\u5b63\\u5ea6\":[35694,56498,58907,44712,36227],\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\":[23604,38138,40357,30998,25119],\"\\u7b2c\\u4e94\\u5b63\\u5ea6\":[13360,20630,22663,19366,16490],\"\\u7b2c\\u56db\\u5b63\\u5ea6\":[44993,75002,78027,57541,47498]},\"selected\":{\"id\":\"1215\"},\"selection_policy\":{\"id\":\"1214\"}},\"id\":\"1156\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"bottom\":{\"expr\":{\"id\":\"1197\"}},\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#fdae61\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#fdae61\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#fdae61\"},\"top\":{\"expr\":{\"id\":\"1198\"}},\"width\":{\"value\":0.8},\"x\":{\"field\":\"area\"}},\"id\":\"1256\",\"type\":\"VBar\"},{\"attributes\":{},\"id\":\"1214\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1156\"}},\"id\":\"1206\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1179\",\"type\":\"ResetTool\"},{\"attributes\":{\"fields\":[\"\\u7b2c\\u4e00\\u5b63\\u5ea6\",\"\\u7b2c\\u4e8c\\u5b63\\u5ea6\"]},\"id\":\"1195\",\"type\":\"Stack\"},{\"attributes\":{\"coordinates\":null,\"formatter\":{\"id\":\"1212\"},\"group\":null,\"major_label_policy\":{\"id\":\"1213\"},\"ticker\":{\"id\":\"1169\"}},\"id\":\"1168\",\"type\":\"CategoricalAxis\"},{\"attributes\":{},\"id\":\"1215\",\"type\":\"Selection\"},{\"attributes\":{\"factors\":[\"\\u5e7f\\u4e1c\\u7701\",\"\\u5317\\u4eac\",\"\\u4e0a\\u6d77\\u5e02\",\"\\u6d59\\u6c5f\\u7701\",\"\\u6c5f\\u82cf\\u7701\"]},\"id\":\"1160\",\"type\":\"FactorRange\"}],\"root_ids\":[\"1157\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.2\"}};\n",
       "  const render_items = [{\"docid\":\"db484674-3bb2-4cf3-9b0c-435e1e493e32\",\"root_ids\":[\"1157\"],\"roots\":{\"1157\":\"346d0282-843a-4b97-8da1-9c073ba9317c\"}}];\n",
       "  root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
       "\n",
       "  }\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    let attempts = 0;\n",
       "    const timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        clearInterval(timer);\n",
       "        embed_document(root);\n",
       "      } else {\n",
       "        attempts++;\n",
       "        if (attempts > 100) {\n",
       "          clearInterval(timer);\n",
       "          console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
       "        }\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "1157"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.palettes import Spectral5\n",
    "from bokeh.core.properties import value\n",
    "area = ['广东省', '北京', '上海市', '浙江省', '江苏省']\n",
    "money = ['第一季度','第二季度','第三季度','第四季度','第五季度']\n",
    "colors = [\"#c9d9d3\", \"#718dbf\", \"#e84d60\",\"#FFB6C1\",\"#C71585\"]\n",
    "data = {'area': area,\n",
    "        '第一季度' : 第一季度,\n",
    "        '第二季度' : 第二季度,\n",
    "        '第三季度' : 第三季度,\n",
    "        '第四季度' : 第四季度,\n",
    "        '第五季度' : 第五季度}\n",
    "\n",
    "source = ColumnDataSource(\n",
    "    data = data\n",
    ")\n",
    "\n",
    "# 点击的交互式数据\n",
    "TOOLTIPS = [\n",
    "#  (\"标题\"，\"数据\")\n",
    "    (\"$name\",\"@area:@$name\")\n",
    "]\n",
    "\n",
    "# 颜色的准备\n",
    "colors = Spectral5\n",
    "\n",
    "# 画布\n",
    "p = figure(\n",
    "    x_range = area,\n",
    "    plot_height=500,\n",
    "    title=\"Fruit Counts by Year\",\n",
    "    tooltips=TOOLTIPS\n",
    ")\n",
    "\n",
    "# 绘图\n",
    "p.vbar_stack(money,x='area',width=0.8,color = colors,source=source,legend=[value(x) for x in money])\n",
    "\n",
    "# # 其他\n",
    "# p.y_range.start = 0\n",
    "# p.y_range.end = 600000\n",
    "# p.x_range.range_padding = 0.1\n",
    "# p.xgrid.grid_line_color = None\n",
    "# p.axis.minor_tick_line_color = None\n",
    "# p.outline_line_color = None\n",
    "# p.legend.location = \"top_left\"\n",
    "# p.legend.orientation = \"horizontal\"\n",
    "# 显示\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
